const Router = require('koa-router');
const auth = require('@/middleware/auth');
const { getCategories, saveCategory, deleteCategory, getAllCategories } = require('@/controller/link/category');
const { getLinks, saveLink, deleteLink, getAllLinks, getCategoryWithLinks } = require('@/controller/link');

const router = new Router({ prefix: '/link' });

// 分类相关接口
router.post('/category/list', getCategories);
router.get('/category/all', getAllCategories); // 不分页获取所有分类
router.post('/category/save', saveCategory);
router.post('/category/delete', auth, deleteCategory);

// 网址相关接口
router.post('/list', getLinks);
router.get('/all', getAllLinks); // 获取所有链接
router.get('/categories-with-links', getCategoryWithLinks); // 获取所有分类及对应的链接
router.post('/save', auth, saveLink);
router.post('/delete', auth, deleteLink);

module.exports = router;